<extend name="Base/common"/>

<block name="style">
    <link href="__CSS__/help.css" rel="stylesheet" type="text/css"/>
</block>

<block name="body">
<div class="col-md-12">
    <include file="Public/user_info"/>
    <include file="Public/_top_menu"/>
</div>

<div class="col-md-12 ">
    <div class="bgwhite pull-left" style="width:100%;min-height: 500px;padding-bottom: 50px;margin-top: 0">
        <div class="help_h" style="">
            <a href="{:U('help/index/detail',array('id'=>$help_id))}" class="pull-left " style="width: 120px;">帮忙描述</a>
            <a href="{:U('help/index/evaluate',array('id'=>$help_id))}" class="pull-left" style="width: 120px;">帮忙评价</a>
            <a href="{:U('help/index/production',array('id'=>$help_id))}" class="pull-left active"
               style="width: 120px;">帮忙作品</a>
        </div>

        <php>if(empty($works) && check_can_edit($help_id)){</php>


        <div class="publish_btn col-xs-12 text-center" style="padding: 120px 0;"><a
                href="{:U('help/index/publishwork',array('id'=>$help_id))}" class="btn btn-primary button_change">发布作品</a></div>
        <div class="clearfix dashed"></div>
        <div style="margin-left:20px;">
            <p>发布事项：</p>

            <p>一、从“帮忙”活动结束日期开始计算，25天内必须上传合作的作品，逾期按违约处理。不开玩笑！</p>

            <p> 二、发布的作品必须为真实合作的作品，一切虚假盗图都将会受到非常非常非常严厉的处罚！</p>

            <p> 三、根据我朝互联网络法律法规，严禁发布色情、暴力等一切违法内容，否则小心查你家水表。</p>
        </div>

        <php>}elseif(!empty($works)){</php>

        <div class=" col-xs-12" style="padding-left: 15px;padding-right: 15px;">
            <div class="help_detail help_production" style="">
                <div class="col-ten-2 col-xs-6" style="">
                    <img src="{:getThumbImageById($works['cover'],168,168)}" style="margin-top: 11px;" class=""/>
                </div>
                <div class="col-ten-2 col-xs-6 pull-right  " style="border-left: 1px solid #ccc;height: 190px;">
                    <div class="vertical_middle" style="height: 190px;">

                        发布于{:date('Y年m月d日',$works['create_time'])}
                        <div>
                            <if condition="check_can_edit($help_id)">
                                <a href="{:U('help/index/publishWork',array('id'=>$help_id))}">编辑</a>
                            </if>
                        </div>
                    </div>
                </div>
                <div class="col-ten-6 col-xs-12  help_detail_info">
                    <div class="">
                        <p class="help_detail_title"> {$works.title}</p>

                        <div class="dashed"></div>
                    </div>
                    <div class="pull-left help_production_info"> {$works.detail}</div>
                </div>
            </div>

            <if condition="$works['video'][1]">
                <div class="pull-left help_detail_description col-xs-12" style="margin:20px 0px">

                    <embed src="{$works.video.1}" wmode="transparent" allowfullscreen="true"
                           type="application/x-shockwave-flash" width="100%" height="500"></embed>

                </div>
                <div class="col-xs-12" style="padding-left: 15px;padding-right: 15px;">
                    <div class="clearfix dashed"></div>
                </div>
            </if>

            <volist name="works.image" id="image">
                <php>$img_src =get_cover($image,'path');
                    $long = false;
                    $size =  getimagesize('http://'.$_SERVER['HTTP_HOST'].$img_src);
                    $size[0] < $size[1] && $long = true;
                </php>
                <div class="text-center"  style="<if condition="$long">width: 70%;<else/>width:100%;</if> margin:0 auto;">
                <div class=" help_detail_description col-xs-12 text-center" style="margin:20px 0px;padding-left: 15px;padding-right: 15px;">
                    <img style="width: 100%" src="{$img_src}">
                </div>
                <div class="col-xs-12" style="padding-left: 15px;padding-right: 15px;">
                    <div class="clearfix dashed"></div>
                </div>
    </div>
            </volist>




            <div class="col-xs-12" style="margin:65px 0">
                <div class="col-md-6" style="float: none;margin: 0 auto">

                    <volist name="attend" id="attend">
                        <div style="float: left;height: 56px;width: 100%">
                            <img src="{$attend.user.avatar64}" style="width: 56px;height: 56px;" class="pull-left"/>

                            <div class="pull-left" style="margin-left: 10px;">
                                <div class="" style="font-size: 16px;color: #fd7700;height: 20px"><a class="author "
                                                                                                     href="{$attend.user.space_url}"
                                                                                                     ucard="{$attend.user.uid}">{$attend.user.nickname}</a>
                                </div>
                                <div style="font-size: 12px;color: #a0a0a0">帮忙项目： {$help.type|get_type}</div>
                                <div class="visible_xxs" style="display:none;margin-left: 2px;">
                                    <a class="attend_support" data-id="{$attend.id}"
                                       data-url="{:U('help/index/attendsupport')}"><span class="thumbs thumbs_up pull-left" <if condition="check_attend_support($attend['id'],1)">style="background-position:0px 0px" title="已赞"</if>></span>
                                        <span class="support_count">{$attend.support}</span></a>
                                    <a class="attend_oppose" data-id="{$attend.id}"
                                       data-url="{:U('help/index/attendsupport')}"><span class=" thumbs thumbs_down pull-left" <if condition="check_attend_support($attend['id'],0)">style="background-position:-27px 0px" title="已踩"</if>></span>
                                        <span class="oppose_count">{$attend.oppose}</span></a>
                                </div>
                            </div>

                            <div class="pull-right hidden_xss" style="font-size: 20px;height: 56px;line-height: 56px">
                                <a class=" attend_support pull-left" data-id="{$attend.id}"
                                   data-url="{:U('help/index/attendsupport')}" style="margin-right:20px; "><span class="thumbs thumbs_up pull-left" <if condition="check_attend_support($attend['id'],1)">style="background-position:0px 0px" title="已赞"</if>></span>

                                    <span class="support_count"> {$attend.support}</span></a>
                                <a class="attend_oppose pull-left" data-id="{$attend.id}"
                                   data-url="{:U('help/index/attendsupport')}"><span class=" thumbs thumbs_down pull-left" <if condition="check_attend_support($attend['id'],0)">style="background-position:-27px 0px" title="已踩"</if>></span>
                                    <span class="oppose_count">{$attend.oppose}</span></a>
                            </div>
                        </div>
                        <div class="solid pull-left" style="margin: 10px 0;width: 100%"></div>
                    </volist>


                </div>

            </div>


            <div class="col-xs-12" style="text-align: center;margin:20px 0">
                <div style="width: 200px;margin: 0 auto">
                    <button class="btn btn-large btn-primary pull-left works_support button_change" data-id="{$help_id}"
                            data-url="{:U('help/index/workssupport')}">
                           <span style="font-size: 20px;">
                                    大片
                            </span>
                    </button>
                    <button class="btn btn-large btn-primary pull-right works_oppose button_change" data-id="{$help_id}"
                            data-url="{:U('help/index/workssupport')}">
                             <span style="font-size: 20px;">
                                    烂片
                            </span>
                    </button>

                    <div class="clearfix">
                        <p> 大片 <span id="works_support">{$works.support}</span></p>

                        <p> 烂片 <span id="works_oppose">{$works.oppose}</span></p>

                        <p> 点评 <span id="works_comment">{$works.comment}</span></p>
                    </div>

                </div>

            </div>


        <div class="col-xs-12" style="padding-left: 15px;padding-right: 15px;">
            <div class="clearfix dashed"></div>
        </div>

            <div class="col-xs-12" style="text-align: center;margin:20px 0">

                {:W('OtherWorks/lists',array('uid'=>$works['help']['uid']))}

            </div>

        <div class="col-xs-12" style="padding-left: 15px;padding-right: 15px;">
            <div class="clearfix dashed"></div>
        </div>
            <div class="col-xs-12 three_words_box" style="text-align: center;margin:65px 0px;">
                {:hook('threeWords',array('model'=>'help_works','row_id'=>$help_id))}
            </div>

        </div>

        <php>}else{</php>
        <div class="row">
            <div class="col-xs-12">
                <p class="text-muted" style="text-align: center; font-size: 3em;">
                    <br/><br/>
                    暂时还未发布作品，请耐心等待~~
                    <br/><br/><br/>
                </p>
            </div>
        </div>
        <php> }</php>
    </div>
</div>

<script>
    $(function () {
        $('.attend_support').click(function () {
            var obj = $(this);
            var url = obj.attr('data-url');
            var attend_id = obj.attr('data-id');
            $.post(url, {attend_id: attend_id, support: 1}, function (res) {
                if (res.status) {
                    toast.success(res.info);
                    $('.support_count').text(parseInt(obj.text()) + 1);
                    $('.thumbs_up').css('background-position','0px 0px');
                } else {
                    toast.error(res.info);
                }
            }, 'json')
        })

        $('.attend_oppose').click(function () {
            var obj = $(this);
            var url = obj.attr('data-url');
            var attend_id = obj.attr('data-id');
            $.post(url, {attend_id: attend_id, support: 0}, function (res) {
                if (res.status) {
                    toast.success(res.info);
                    $('.oppose_count').text(parseInt(obj.text()) + 1);
                    $('.thumbs_down').css('background-position','-27px 0px');

                } else {
                    toast.error(res.info);
                }
            }, 'json')
        })


        $('.works_support').click(function () {
            var obj = $(this);
            var url = obj.attr('data-url');
            var help_id = obj.attr('data-id');
            $.post(url, {help_id: help_id, support: 1}, function (res) {
                if (res.status) {
                    toast.success(res.info);

                    $('#works_support').text(parseInt($('#works_support').text()) + 1);

                } else {
                    toast.error(res.info);
                }
            }, 'json')
        })

        $('.works_oppose').click(function () {
            var obj = $(this);
            var url = obj.attr('data-url');
            var help_id = obj.attr('data-id');
            $.post(url, {help_id: help_id, support: 0}, function (res) {
                if (res.status) {
                    toast.success(res.info);

                    $('#works_oppose').text(parseInt($('#works_oppose').text()) + 1);
                } else {
                    toast.error(res.info);
                }
            }, 'json')
        })
    })
</script>
</block>

